package com.bootdo.wxnotify;

import org.dom4j.Element;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 　　*
    事件主题
    @author 郝江波
 　　* @date 2019/9/7 11:48
 　　*/
public  class WxEventSubject {
    private static CopyOnWriteArrayList<WxEventObserver> wxEventObservers  = new CopyOnWriteArrayList();

    public static void  putEvent( Element rootElement ){
        notifyAllElements(rootElement);
    }
    public void attach(WxEventObserver observer){
        wxEventObservers.add(observer);
    }
    private  static void  notifyAllElements(Element rootElement){
        for(WxEventObserver item : wxEventObservers){
            item.notify(rootElement);
        }
    }
}
